#!/bin/bash
echo "start import db"
pwd=q1w2Q!W@
#req_url=http://localhost:8080/demoapp/test/importcertinfo2db
req_url=http://172.17.196.8:8080/iis/importcertinfo2db
line_num=0
process_file=successFile.txt
if [ -n "$1" ];then
    process_file=$1
    echo "设置了参数：$1"
fi
echo "当前处理文件：$process_file"
for line in $(cat $process_file)
do
    ((line_num++))
    echo "================================================================================"
    echo "当前行:$line_num,数据：$line"
    var_num=0
    arr=(${line//#/ })
    name=${arr[0]}
    certId=${arr[1]}
    resultStr=${arr[2]}
    echo "name=$name&certId=$certId&resultStr=$resultStr"
    import_cmd="curl $req_url --data-urlencode name=$name --data-urlencode pwd=$pwd --data-urlencode certId=$certId --data-urlencode resultStr=$resultStr"
    echo $import_cmd 
    echo $import_cmd >> import_db.log
    result=`$import_cmd`
    echo "执行结果：$result"
#    for var in ${arr[@]}
#    do
#        ((var_num++))
#        echo "第$var_num参数的值：$var"
#        echo "第$var_num参数的值：${arr[0]}"
#    done
done
echo "complete import db"
